Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v8.x backport] errors: make code property mutable #16078

Closed
wants to merge 2 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Oct 8, 2017

Userland code can break if it depends on a mutable code property for
errors. Allow users to change the code property but do not propagate
changes to the error name.

Additionally, make message and name consistent with Error object
(non-enumerable). Test that console.log() and .toString() calls on
internal Error objects with mutated properties have analogous results
with the standard ECMAScript Error objects.

Fixes: #15658

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

errors

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. v8.x labels Oct 8, 2017
@Trott Trott mentioned this pull request Oct 8, 2017
3 tasks
Copy link
Contributor

@evanlucas evanlucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but definitely needs a rebase following 8.7.0

Trott and others added 2 commits October 12, 2017 06:37
Userland code can break if it depends on a mutable `code` property for
errors. Allow users to change the `code` property but do not propagate
changes to the error `name`.

Additionally, make `message` and `name` consistent with `Error` object
(non-enumerable). Test that `console.log()` and `.toString()` calls on
internal `Error` objects with mutated properties have analogous results
with the standard ECMAScript `Error` objects.

PR-URL: nodejs#15694
Fixes: nodejs#15658
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
For internal errors, make `code` and `name` settable while keeping them
non-own properties by default.

PR-URL: nodejs#15694
Fixes: nodejs#15658
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@Trott
Copy link
Member Author

Trott commented Oct 12, 2017

Rebased.

@Trott Trott changed the title [v8x backport] errors: make code property mutable [v8.x backport] errors: make code property mutable Oct 20, 2017
@evanlucas
Copy link
Contributor

evanlucas commented Oct 23, 2017

Landed in 0bd2fd5 and 939a580. Thanks!

@evanlucas evanlucas closed this Oct 23, 2017
evanlucas pushed a commit that referenced this pull request Oct 23, 2017
Userland code can break if it depends on a mutable `code` property for
errors. Allow users to change the `code` property but do not propagate
changes to the error `name`.

Additionally, make `message` and `name` consistent with `Error` object
(non-enumerable). Test that `console.log()` and `.toString()` calls on
internal `Error` objects with mutated properties have analogous results
with the standard ECMAScript `Error` objects.

Backport-PR-URL: #16078
PR-URL: #15694
Fixes: #15658
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
evanlucas pushed a commit that referenced this pull request Oct 23, 2017
For internal errors, make `code` and `name` settable while keeping them
non-own properties by default.

Backport-PR-URL: #16078
PR-URL: #15694
Fixes: #15658
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@Trott Trott deleted the backport-15694 branch January 13, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants